package com.library.mapper;

import com.library.entity.Follow;
import com.library.vo.UserProfileVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FollowMapper {
    /**
     * 查询粉丝数量
     * @param userId
     * @return
     */
    @Select("select count(*) from follow where follow_user_id = #{userId}")
    Integer countFans(Long userId);

    /**
     * 查询关注数量
     * @param userId
     * @return
     */
    @Select("select count(*) from follow where user_id = #{userId}")
    Integer countFollows(Long userId);

    @Insert("insert into follow(user_id, follow_user_id) values(#{userId}, #{followUserId})")
    void follow(Follow follow);

    /**
     * 查询用户的关注者列表
     * @param userId
     * @return
     */
    List<UserProfileVO> getFollowers(Long userId);

    /**
     * 查询用户的关注列表
     * @param userId
     * @return
     */
    List<UserProfileVO> getFollowing(Long userId);
}
